auxiliary.js ➔ tableReset   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
1
// jshint esversion: 8
2
3
const {
4
  resetObject
5
} = require('../../common/resetObject');
6
7
/*
8
  tableReset
9
    Reset bulk whois processing table contents
10
  parameters
11
    dLength (integer) -
12
    tLength (integer) -
13
 */
14
function tableReset(dLength = 0, tLength = 0) {
15
  $('#bwProcessingSpanProcessed').text(0);
16
  $('#bwProcessingSpanWaiting').text(0);
17
  $('#bwProcessingSpanTotal').text(dLength * tLength);
18
19
  $('#bwProcessingSpanStatusavailable').text(0);
20
  $('#bwProcessingSpanStatusunavailable').text(0);
21
  $('#bwProcessingSpanStatuserror').text(0);
22
23
  return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
24
}
25
26
/*
27
  getExportOptions
28
    Get export options after bulk whois processing is finished
29
 */
30
function getExportOptions() {
31
  return {
32
    'filetype': $('#bwExportSelectFiletype').val(),
33
    'domains': $('#bwExportSelectDomains').val(),
34
    'errors': $('#bwExportSelectErrors').val(),
35
    'information': $('#bwExportSelectInformation').val(),
36
    'whoisreply': $('#bwExportSelectReply').val()
37
  };
38
}
39
40
/*
41
  setExportOptions
42
    Sets export options to a default preset
43
  parameters
44
    preset (string) - Use a determined string formatted preset for export
45
 */
46
function setExportOptions(preset) {
47
  switch (preset) {
48
    case ('none'):
49
      unlockFields();
50
      break;
51
    // Export available only
52
    case ('availableonly'):
53
      unlockFields();
54
      //$('#bweSelectFiletype').val('csv');
55
      $('#bwExportSelectDomains').val('available');
56
      $('#bwExportSelectErrors').val('no');
57
      $('#bwExportSelectInformation').val('domain');
58
      $('#bwExportSelectReply').val('no');
59
      break;
60
    // All results but no reply nor debug
61
    case ('allbutnoreply'):
62
      unlockFields();
63
      //$('#bweSelectFiletype').val('csv');
64
      $('#bwExportSelectDomains').val('both');
65
      $('#bwExportSelectErrors').val('yes');
66
      $('#bwExportSelectInformation').val('domain+basic');
67
      $('#bwExportSelectReply').val('no');
68
      break;
69
    // Bulk whois analyser import optimized
70
    case ('import'):
71
      lockFields();
72
      $('#bwExportSelectFiletype').val('csv');
73
      $('#bwExportSelectDomains').val('both');
74
      $('#bwExportSelectErrors').val('yes');
75
      $('#bwExportSelectInformation').val('domain+basic+debug');
76
      $('#bwExportSelectReply').val('yes+block');
77
      break;
78
  }
79
80
  return;
81
}
82
83
/*
84
  setExportOptionsEx
85
    Set bulk whois filetype export option
86
  parameters
87
    filetype (string) - Filetype, set field locks if is txt file
88
 */
89
function setExportOptionsEx(filetype) {
90
  switch (filetype) {
91
    case 'txt':
92
      lockFields(true);
93
      break;
94
    case 'csv':
95
      unlockFields(true);
96
      break;
97
  }
98
99
  return;
100
}
101
102
/*
103
  lockFields
104
    Locks export fields depending on filetype
105
  parameters
106
    isTxt (boolean) - Is text (.txt) filetype
107
 */
108
function lockFields(isTxt = false) {
109
  if (isTxt === false) {
110
    $('#bwExportSelectFiletype').prop("disabled", true);
111
    $('#bwExportSelectDomains').prop("disabled", true);
112
    $('#bwExportSelectErrors').prop("disabled", true);
113
  }
114
  if ($('#bwExportSelectReply').prop("disabled") === false) {
115
    $('#bwExportSelectInformation').prop("disabled", true);
116
    $('#bwExportSelectReply').prop("disabled", true);
117
  }
118
119
  return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
120
}
121
122
/*
123
  unlockFields
124
    Unlocks export fields depending on filetype
125
  parameters
126
    isTxt (boolean) - Is text (.txt) filetype
127
 */
128
function unlockFields(isTxt = false) {
129
  if (isTxt === true) {
130
    $('#bwExportSelectFiletype').prop("disabled", false);
131
  }
132
  if ($('#bwExportSelectReply').prop("disabled") === true && $('#bwExportSelectFiletype').val() == 'csv') {
133
    $('#bwExportSelectFiletype').prop("disabled", false);
134
    $('#bwExportSelectDomains').prop("disabled", false);
135
    $('#bwExportSelectErrors').prop("disabled", false);
136
    $('#bwExportSelectInformation').prop("disabled", false);
137
    $('#bwExportSelectReply').prop("disabled", false);
138
  }
139
140
  return;
0 ignored issues
show
Unused Code introduced by
This return has no effect and can be removed.
Loading history...
141
}
142
143
module.exports = {
144
  tableReset: tableReset,
145
  tblReset: tableReset,
146
  getExportOptions: getExportOptions,
147
  getExprtOptns: getExportOptions,
148
  setExportOptions: setExportOptions,
149
  setExprtOptns: setExportOptions,
150
  setExportOptionsEx: setExportOptionsEx
151
};
152